package com.example.administrator.hello.AndroidText;

import android.support.test.uiautomator.UiObject2;

/**
 * Created by Administrator on 2017/7/15.
 */

public class PageLogin {

    private Finder finder;

    public PageLogin(Finder helper) {
        this.finder = helper;
    }

    public UiObject2 getPhoneET() {
        return finder.findById("net.oschina.app:id/et_login_username");
    }

    public UiObject2 getPwdET() {
        return finder.findById("net.oschina.app:id/et_login_pwd");
    }

    public UiObject2 getLoginBtn() {
        return finder.findById("net.oschina.app:id/bt_login_submit");
    }

    public void enterPhone(String number) {
        getPhoneET().setText(number);
    }

    public void enterPwd(String pwd) {
        getPwdET().setText(pwd);
    }

    public void clearPhone() {
        getPhoneET().click();
        getPhoneET().clear();
    }


    public void clearPwd() {
        getPwdET().click();
        getPwdET().clear();
    }

    public void clickLoginBtn() {
        getLoginBtn().click();
    }

    public void login(String number, String pwd) {
        clearPhone();
        enterPhone(number);
        clearPwd();
        enterPwd(pwd);
        clickLoginBtn();
    }
}
